const Books = require("./../db/books");

module.exports = {
  getAllBooks: (req, res, next) => {
    Books.getBookInfo(true).then((data) => {
      res.json({
        result: 0,
        data,
      });
    });
  },
  
  getBookById: (req, res, next) => {
    const { bookid } = req.qury;
    if (!bookid) {
      res.json({
        result: -1,
        errMsg: "缺少参数"
      })
      return
    }
    Books.getBookInfo(false, bookid).then((data) => {
      res.json({
        result: 0,
        data,
      });
    });
  }
};
